package c.c.b.b;

import android.content.Context;
import android.content.SharedPreferences;
import android.text.TextUtils;
import c.c.b.b.e.a;
import c.c.b.b.e.b;
import c.c.b.b.e.e;
import c.c.b.b.e.f;
import c.c.b.b.f.d;
import c.c.b.b.f.h;
import c.c.b.b.f.j;
import c.c.b.b.f.l;
import c.c.b.b.f.n;
import c.c.b.b.f.o;
import c.c.b.b.f.q;
import java.io.File;

/* compiled from: AdNetSdk */
public class c {
    public static String a = null;
    public static b b = null;
    public static boolean c = true;
    public static a d;

    public static b a() {
        b bVar = b;
        if (bVar != null) {
            return bVar;
        }
        throw new IllegalArgumentException("sITTNetDepend is null");
    }

    public static o b(Context context) {
        o oVar = new o(new j(new File(d(context), "reqQueue")), new d(new n()));
        h hVar = oVar.i;
        if (hVar != null) {
            hVar.e = true;
            hVar.interrupt();
        }
        for (l lVar : oVar.h) {
            if (lVar != null) {
                lVar.e = true;
                lVar.interrupt();
            }
        }
        hVar = new h(oVar.c, oVar.d, oVar.e, oVar.g);
        oVar.i = hVar;
        hVar.setName("tt_pangle_thread_CacheDispatcher");
        oVar.i.start();
        for (int i = 0; i < oVar.h.length; i++) {
            l lVar2 = new l(oVar.d, oVar.f, oVar.e, oVar.g);
            StringBuilder stringBuilder = new StringBuilder();
            stringBuilder.append("tt_pangle_thread_NetworkDispatcher");
            stringBuilder.append(i);
            lVar2.setName(stringBuilder.toString());
            oVar.h[i] = lVar2;
            lVar2.start();
        }
        return oVar;
    }

    public static void c(Context context, boolean z) {
        boolean z2;
        f a = f.a();
        boolean a2 = c.c.b.b.g.c.a(context);
        synchronized (a) {
            z2 = true;
            if (!a.b) {
                a.c = context;
                a.m = a2;
                a.d = new e(context, a2);
                if (a2) {
                    SharedPreferences sharedPreferences = a.c.getSharedPreferences("ttnet_tnc_config", 0);
                    a.e = sharedPreferences.getInt("tnc_probe_cmd", 0);
                    a.f = sharedPreferences.getLong("tnc_probe_version", 19700101000L);
                }
                StringBuilder stringBuilder = new StringBuilder();
                stringBuilder.append("initTnc, isMainProc: ");
                stringBuilder.append(a2);
                stringBuilder.append(" probeCmd: ");
                stringBuilder.append(a.e);
                stringBuilder.append(" probeVersion: ");
                stringBuilder.append(a.f);
                c.c.b.b.g.b.a("TNCManager", stringBuilder.toString());
                a.b = true;
            }
        }
        String b = c.c.b.b.g.c.b(context);
        if (b == null || !(b.endsWith(":push") || b.endsWith(":pushservice"))) {
            z2 = false;
        }
        if (z2 || (!c.c.b.b.g.c.a(context) && z)) {
            c.c.b.b.b.a.a(context).i();
            c.c.b.b.b.a.a(context).c(false);
        }
        if (c.c.b.b.g.c.a(context)) {
            c.c.b.b.b.a.a(context);
        }
    }

    public static String d(Context context) {
        try {
            if (TextUtils.isEmpty(a)) {
                File file = new File(context.getCacheDir(), "VAdNetSdk");
                file.mkdirs();
                a = file.getAbsolutePath();
            }
        } catch (Throwable th) {
            q.b(th, "init adnetsdk default directory error ", new Object[0]);
        }
        return a;
    }
}
